﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Windows.Forms;

public partial class User_information : System.Web.UI.Page
{
    string strconn = ConfigurationManager.ConnectionStrings["a123"].ToString();
    SqlConnection sqlconn;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bind();

        }
    }
    
    protected void Button1_Click(object sender, EventArgs e)
    {
        //string number = GridView1.Rows[i].Cells[4].Text;

        sqlconn = new SqlConnection(strconn);

            //bookId = GridView1.DataKeys[i].Value;
            System.Web.UI.WebControls.TextBox L1 = (System.Web.UI.WebControls.TextBox)DetailsView1.Rows[2].FindControl("TextBox3");
            System.Web.UI.WebControls.TextBox L2 = (System.Web.UI.WebControls.TextBox)DetailsView1.Rows[3].FindControl("TextBox4");
            string sqlstr = "update tb_Member set RealName='"+L1.Text+"',Address='"+L2.Text+"' where UserName='"+DetailsView1.Rows[0].Cells[1].Text+"'";
            sqlconn.Open();
            SqlCommand sqlcom = new SqlCommand(sqlstr, sqlconn);
            sqlcom.ExecuteNonQuery();
            sqlconn.Close();
            //bind();
            Response.Write("成功");
    }
    public void bind()
    {
        sqlconn = new SqlConnection(strconn);
        sqlconn.Open();
        string sqlstr = "select * from tb_Member where UserName='" + Session["ID"] + "'";
        SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlconn);
        DataSet myds = new DataSet();
        myda.Fill(myds, "tb_Member");
        
        DetailsView1.DataSource = myds;
        DetailsView1.DataKeyNames = new string[] { "UserName" };
        DetailsView1.DataBind();
        sqlconn.Close();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Re_passwd1.aspx");
    }
}